package jk.zmn.socket.udp;

import java.net.*;

/**
 * @author 张梦楠
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2018/5/3010:47
 * @blog www.itzmn.com
 *
 *  UPD客户端
 *  1.创建客户端
 *  2.打包数据
 *  3.发送数据
 *  4.关闭流
 *
 */
public class Client {
     public static void main(String[] args) throws Exception {

         DatagramSocket client = new DatagramSocket(6666);

         String msg = "世界你好";
         byte[] data = msg.getBytes();

         //创建数据包
         DatagramPacket packet = new DatagramPacket(data, data.length, new InetSocketAddress("localhost", 8888));

         client.send(packet);

         client.close();



     }
}
